﻿using Shape.Mvp.Commands;
using Shape.Mvp.Persistence.Conversations;
using Shape.Mvp.Sample.Conversations.Presenters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shape.Mvp.Sample.Conversations.Commands
{
	public class ApplicationStartCommand : Conversationalist, ICommand
	{
		private readonly IApplicationController _applicationController;
		private readonly CakeListPresenter _cakeListPresenter;

		public ApplicationStartCommand(
			CakeListPresenter cakeListPresenter, 
			IApplicationController applicationController,
			IConversationContainerAccessor conversationContainerAccessor,
			IConversationFactory conversationFactory) : base(conversationContainerAccessor, conversationFactory)
		{
			_applicationController = applicationController;
			_cakeListPresenter = cakeListPresenter;
		}

		public void Execute()
		{
			using (MyOwnConversation())
			{
				_cakeListPresenter.Initialise();

				_applicationController.Show(_cakeListPresenter.View).AsMainWindow();
			}
			
		}
	}
}
